const Router = require('koa-router')
const {
  create,
  getUserData,
  getUserDesc,
  getUserProfile,
  updatePassword,
  avatarInfo,
  wallInfo,
  updateNickname,
  updateUserDesc,
  updateUserData
} = require('../controller/user.controller')
const { verifyUser, handlePassword, verifyPassword } = require('../middleware/user.middleware')
const { verifyAuth } = require('../middleware/auth.middleware')


const userRouter = new Router({ prefix: "/user" }) // 添加路由前缀

// 注册
userRouter.post("/", verifyUser, handlePassword, create)

// 获取用户各项数据
userRouter.get("/data", getUserData)

// 获取用户详情
userRouter.get("/desc", getUserDesc)

// 获取用户全部数据
userRouter.get("/profile", getUserProfile)

// 修改用户密码
userRouter.put("/updatePassword", verifyAuth, verifyPassword, updatePassword)

// 获取用户头像
userRouter.get("/avatar/:userId", avatarInfo)

// 获取用户壁纸
userRouter.get("/wall/:userId", wallInfo)

// 修改用户名
userRouter.put("/updateNickname", verifyAuth, updateNickname)

// 修改用户详情
userRouter.put("/updateUserDesc", verifyAuth, updateUserDesc)

// 修改用户数据
userRouter.put("/updateUserData", verifyAuth, updateUserData)

module.exports = userRouter
